package com.dongzili.common.mybatisplus;

import java.util.concurrent.ConcurrentHashMap;

public class PageTotalCache {
    private static final ConcurrentHashMap<String, Long> TOTAL_CACHE = new ConcurrentHashMap<>();
    
    // 生成缓存键（根据方法签名和参数）
    public static String generateKey(String methodName, Object params) {
        return methodName + ":" + (params != null ? params.hashCode() : 0);
    }
    
    // 存储总数
    public static void putTotal(String key, Long total) {
        TOTAL_CACHE.put(key, total);
    }
    
    // 获取总数
    public static Long getTotal(String key) {
        return TOTAL_CACHE.get(key);
    }
    
    // 清除缓存（可选）
    public static void clearCache(String key) {
        TOTAL_CACHE.remove(key);
    }
}